#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    int lines;
    cin >> lines;
    for(int i = 0; i < lines; i++)
    {
        int n;
        cin >> n;
        float ave = 0;
        float * p = new float[n];
        for(int i = 0; i<n; i++)
        {
            float temp;
            cin >> temp;
            p[i] = temp;
            ave += temp;
        
        }
        ave /=n;
        int num = 0;
         for(int i = 0; i<n; i++)
        {
             if(p[i] > ave)
                 num++;
         }
        cout << num << endl;
        delete [] p;
    }
}